<template>
  <div class="mod-distribution-user">
    <avue-crud
      ref="crud"
      :page="page"
      :data="dataList"
      v-model="dataForm"
      :table-loading="dataListLoading"
      :option="tableOption"
      @search-change="searchChange"
      @refresh-change="refreshChange"
      @on-load="getDataList"
    >
      <template slot-scope="scope" slot="nickName">{{scope.row.distributionUser.nickName}}</template>

      <template slot-scope="scope" slot="userMobile">{{scope.row.distributionUser.userMobile}}</template>

      <template slot-scope="scope" slot="username">{{scope.row.sysUser.username}}</template>
    </avue-crud>
  </div>
</template>

<script>
import { tableOption } from '@/crud/distribution/user/distributionBan'
export default {
  data () {
    return {
      createdateRange: [],
      dataForm: {
        userMobile: null
      },
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 20 // 每页显示多少条
      },
      searchForm: {},
      dataList: [],
      tableOption: tableOption,
      dataListLoading: false,
      dataListSelections: [],
      addOrUpdateVisible: false
    }
  },
  components: {
  },
  methods: {
    // 刷新回调
    refreshChange () {
      this.page = this.$refs.crud.$refs.tablePage.defaultPage
      this.getDataList(this.page)
    },
    // 点击查询
    searchChange (params) {
      this.page.currentPage = 1

      this.searchForm = params
      this.getDataList(this.page)
    },
    // 获取数据列表
    getDataList (page) {
      this.dataListLoading = true
      this.$http({
        url: this.$http.adornUrl('/distribution/distributionUserBan/page/anduser'),
        method: 'get',
        params: this.$http.adornParams(Object.assign({
          current: page ? page.currentPage : 1,
          size: page ? page.pageSize : 20
        }, this.searchForm))
      }).then(({ data }) => {
        this.page.total = data.total
        this.page.pageSize = data.size
        this.page.currentPage = data.current

        this.dataList = data.records
        this.dataListLoading = false
      })
    }
  }
}
</script>
<style scoped>
div /deep/ .avue-crud__menu{
    overflow:inherit;
    min-height: 0;
}
div /deep/ .avue-crud__right{
    position: absolute;
    right: 0;
    top: -58px;
}
div /deep/ .avue-crud__pagination{
  margin-bottom: 25px;
}
</style>
